package com.ctrip.ec.api.admin;


import com.ctrip.ec.api.admin.filter.AuthFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;
import javax.servlet.MultipartConfigElement;

/**
 * Created by jiangzy on 2018/8/20.
 */
@Configuration
public class AppConfig {
    @Bean
    public FilterRegistrationBean authFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new AuthFilter());
        registration.setDispatcherTypes(DispatcherType.REQUEST);
        return registration;
    }



    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(1024L * 1024L);
        return factory.createMultipartConfig();
    }

    public  String hello(){
        return "hello";
    }

}
